<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends DQ_Controller 
{
    public function __construct()
    {
        parent::__construct();
    }

	public function index()
	{
        $num = 20+1;

        $target_uid = (int) $this->input->get('uid');

        if( $this->session->userdata('uid') && $target_uid === (int)$this->session->userdata('uid'))
        {
            $self = true;
        }
        else
        {
            $self = false;
        }

        $this->load->Model('user_model');
        $this->load->Model('thread_model');
        $userInfo = $this->user_model->getUserInfoDetail(array('uid'=>$target_uid));

        if($userInfo['error'] != 0)
        {
            error_page(NO_ONE);
            return;
        }

        $threads = $this->thread_model->getMyThreads(array('fid'=>0,'from'=>0,'limit'=>$num,'authorid'=>$target_uid));
        $threads_data = $threads['data'];

        $next = count($threads_data) == $num ? 1:0;

        if($next)
        {
            array_pop($threads_data);
        }

		$this->load->view('user/index',array('userInfo'=>$userInfo['data'],'threads'=>$threads_data,'next'=>$next,'num'=>$num,'self'=>$self));
	}

    public function suggest()
    {
        $this->load->view('common/suggest');
    }
}

